<?php
/* @var $this BodegaSateliteController */
/* @var $model bodegaSatelite */


Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
});
$('.search-form form').submit(function(){
	$('#bodega-satelite-grid').yiiGridView('update', {
		data: $(this).serialize()
	});
	return false;
});
");
?>
<!-- ________________________________ Muestra el mesaje de error de datos asociados ________________________________________-->
<div id="statusMsg">
<?php if(Yii::app()->user->getFlash('error')):?>
    <div class="flash-error">
        <?php echo Yii::app()->user->getFlash('error'); ?>
    </div>
<?php endif; ?>
</div>
<?php if (Yii::app()->user->hasFlash('success')): ?>
  <div class="alert alert-success">
    <?php echo Yii::app()->user->getFlash('success'); ?>
  </div>
<?php endif ?>
<?php if (Yii::app()->user->hasFlash('error')): ?>
  <div class="alert">
    <?php echo Yii::app()->user->getFlash('error'); ?>
  </div>
<?php endif ?>

<h2>Inventario en bodegas satélites</h2>




<!-- _________________________________________ Tooltip __________________________________________________________ -->
<?php
$this->widget('application.extensions.tipsy.Tipsy', array(
  'fade' => false,
  'gravity' => 'n',
  'items' => array(
    array('id' => '.tooltipster'),
    array('id' => '#tooltipster'),
    array('id' => array('model' => $model, 'attribute' => 'model_attribute_name')
     ,'fallback' => 'Put custom tooltip here.' ),    
  ),  
));
?>

<!-- _________________________________________ Botton agregar productos__________________________________________ -->
<p align="right">
<?php //boton 
$this->widget('bootstrap.widgets.TbButton', array(
       'label'=>'Agregar producto',
       'type'=>'primary',
       'size'=>'medium',
       'url'=>array('bodegaSatelite/create'),

   )); //fin boton ?>

</p>


<!-- _________________________________________ Paginación _________________________________________________________ -->

<div align="right">

<?php
    $this->widget('ext.PageSize.EPageSize', array(
    'gridViewId' => 'bodega-satelite-grid',
    'beforeLabel'=>'Registro por pantalla: ',
    'pageSize' => Yii::app()->request->getParam('pageSize',null),
    'defaultPageSize' =>  10 ,   // may use this :  Yii::app()->params['defaultPageSize'],
    'pageSizeOptions'=> array(5=>5, 10=>10, 25=>25, 50=>50, 75=>75, 100=>100), // you can config it in main.php under the config dir . Yii::app()->params['pageSizeOptions'],// Optional, you can use with the widget default
    ));
    ?>
 
 
<?php
$dataProvider = $model->search();
$pageSize = Yii::app()->user->getState('pageSize',10/*Yii::app()->params['defaultPageSize']*/);
$dataProvider->getPagination()->setPageSize($pageSize);
 
 ?>

</div>

<!-- _________________________________________ Gridview _________________________________________________________ -->

<?php $this->widget('bootstrap.widgets.TbGridView', array(
	'type'=>'striped bordered condensed',
	'id'=>'bodega-satelite-grid',
	 'dataProvider'=>$model->search(),
	'filter'=>$model,


	'template'=>"{summary}{items}{pager}",
	'itemsCssClass'=>'table table-striped table-bordered table-condensed tableNews',// mover por fila
    'enablePagination' => true,
	'columns'=>array(
		array('name'=>'Bo_idcodigo_FK','value'=>'$data->bodega->Bo_nombrebodega','type'=>'text'),   
		array('name'=>'Pr_idproducto_FK','header'=>'Código Producto'),
		array('name'=>'descripcion','value'=>'$data->producto->Pr_descripcion','header'=>'Descripción'),
		array('name'=>'unidad','value'=>'$data->producto->Pr_unidadmedida','header'=>'Unidad de medida'),
		array('name'=>'concurso','value'=>'$data->producto->Pr_numconcurso','header'=>'Concurso'),
		array('name'=>'cod_proveedor','value'=>'$data->producto->Pro_idproveedor_FK','header'=>'Proveedor'),
		array('name'=>'precio','value'=>'$data->producto->Pr_precio','header'=>'Precio'),
		array('name'=>'can_minima','value'=>'$data->producto->Pr_cantidadminima','header'=>'Cantidad mínima'),
		array('name'=>'Bp_cantdespachada','header'=>'Cantidad'),
		array(
            'class'=>'bootstrap.widgets.TbButtonColumn',
            'htmlOptions'=>array('style'=>'width: 50px'),
            'afterDelete'=>'function(link,success,data){ if(success) $("#statusMsg").html(data); }',

        ),
	),
)); ?>



